////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		CPowerUp.h
//
//		Author			:		Kevin Jordan
//
//		Purpose			:		A header for all functions and members of the PowerUp class
//
//		Dates			:		Written( March 1, 2011 ) by Kevin Jordan		LastUpdate( March 1, 2011  ) by Kevin Jordan 
//	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "CPowerUp.h"
#include "SGD Wrappers/CSGD_TextureManager.h"
#include "SGD Wrappers/CSGD_Direct3D.h"
#include "VIN_ObjectManager.h"
#include "CPlayer.h"


CPowerUp::CPowerUp()
{
	SetPowerUpType(POW_NULL);
	SetType(OBJ_POWERUP);
}

CPowerUp::~CPowerUp()
{

}

void CPowerUp::Render()
{
	CSGD_TextureManager* pTM = CSGD_TextureManager::GetInstance();
	pTM->Draw( GetImageID(), (int)GetPosX(), (int)GetPosY(), 1.0f, 1.0f );

	RECT Collision;
	SetRect( &Collision, (int)GetPosX(), (int)GetPosY(), int(GetPosX() + GetWidth()), int(GetPosY() + GetHeight()) );
}

void CPowerUp::Update( float fElapsedTime )
{
	CBaseObject::Update(fElapsedTime);
}

RECT CPowerUp::GetRect()
{
	RECT CollisionRect;
	SetRect(&CollisionRect, (int)GetPosX(), (int)GetPosY(), (int)(GetPosX() + GetWidth()), (int)(GetPosY() + GetHeight()));
	return CollisionRect;
}

bool CPowerUp::CheckCollision( IBaseInterface* pBase )
{
	RECT TempRect;

	if(IntersectRect(&TempRect, &GetRect(), &pBase->GetRect() ) )
	{
		if( pBase->GetType() == OBJ_PLAYER )
		{	CPlayer* pPBase = (CPlayer*)pBase;

		if( GetPowerUpType() == POW_COM )
		{	
			pPBase->SetCombat( pPBase->GetCombat() + 5);
			pPBase->Deadly(true);
			VIN_ObjectManager::GetInstance()->RemoveObject(2, this);
			return true;
		}
		else if( GetPowerUpType() == POW_SPD )
		{
			pPBase->SetSpeed( pPBase->GetSpeed() + 5);
			pPBase->Fast(true);
			VIN_ObjectManager::GetInstance()->RemoveObject(2, this);
			return true;
		}
		else if( GetPowerUpType() == POW_RAGE )
		{
			pPBase->SetRage( pPBase->GetRage() + 5);
			pPBase->Pissed(true);
			VIN_ObjectManager::GetInstance()->RemoveObject(2, this);				
			return true;
		}			
		else if( GetPowerUpType() == POW_DURA )
		{
			pPBase->SetDurability( pPBase->GetDurability() + 5);
			pPBase->Durable(true);
			VIN_ObjectManager::GetInstance()->RemoveObject(2, this);
			return true;
		}
		else if( GetPowerUpType() == POW_COL )
		{	pPBase->IncCollection();
		VIN_ObjectManager::GetInstance()->RemoveObject(2, this);
		return true;
		}
		}
	}
	return false;
}